home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: A4Stuff.h
- * ©1993-1995 metrowerks Inc. All rights reserved
- *
- * Content: CodeResource / DRVR / DA support functions
- *
- * 3 macros have been added to help with setting up the global
- * world for callbacks. They are platform (68K and PPC) safe.
- * Call PrepareCallback() only after A4 is correct. It must be
- * called in the same segment as the callback. Call EnterCallback()
- * when you enter a callback that accesses globals or strings.
- * Call ExitCallback() when you are ready to leave the callback.
- * Please see A4Stuff.h for similiar functions to be used when
- * you enter or exit the main entry point of a code resource.
- */
-
- #ifndef __SETUPA4__
- #define __SETUPA4__
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifndef powerc
-
- #define PrepareCallback() RememberA4()
- #define EnterCallback() long oldA4 = SetUpA4()
- #define ExitCallback() RestoreA4(oldA4)
-
- static void RememberA4(void);
-
- static asm long SetUpA4(void)
- {
- move.l a4,d0
- lea storage,a4
- move.l (a4),a4
- rts
-
- storage: dc.l 0 /* this storage is only referenced thru data cache */
-
- entry static RememberA4
- lea storage,a0
- move.l a4,(a0)
- rts
- }
-
- static long RestoreA4(long:__D0):__D0 = 0xC18C;
-
- #else
-
- #define PrepareCallback()
- #define EnterCallback()
- #define ExitCallback()
- #define RememberA4() 0
- #define SetUpA4() 0L
- #define RestoreA4(x) 0L
-
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-